<include file="../header" />
</head>
<body class="J_scroll_fixed">
<script type="text/javascript">

    var ids = new Array();
    var rowNum = 0;
    function onlyNumber(obj){
        //得到第一个字符是否为负号
        var t = obj.value.charAt(0);
        //先把非数字的都替换掉，除了数字和.
        if(obj.value != 0)
        obj.value = obj.value.replace(/[^\d\.]/g,'').replace(/^0{1,}/g,'');
        //必须保证第一个为数字而不是.
        obj.value = obj.value.replace(/^\./g,'');
        //保证只有出现一个.而没有多个.
        obj.value = obj.value.replace(/\.{2,}/g,'.');
        //保证.只出现一次，而不能出现两次以上
        obj.value = obj.value.replace('.','$#$').replace(/\./g,'').replace('$#$','.');
        //只能输入两位小数
        obj.value = obj.value.replace(/^(\-)*(\d+)\.(\d\d).*$/,'$1$2.$3');
        //如果第一位是负号，则允许添加
        if(t == '-'){
            return;
        }

        var index = obj.name.substring(obj.name.indexOf("_") + 1, obj.name.length);
        var numberName = "number_" + index;
        var number = parseFloat($("input[name="+numberName+"]").val());
        var storageNumber = parseFloat($("input[name=storage_number_"+index+"]").val());
        if(number > storageNumber){
            $("input[name="+numberName+"]").val(storageNumber);
            alert("超出库存剩余：" + storageNumber);
            number = storageNumber;
        }
        var priceName = "price_" + index;
        var price = parseFloat($("input[name="+priceName+"]").val());
        var totalPriceName = "total_price_" + index;
        $("input[name="+totalPriceName+"]").val(price*number);
    }

    function insertRows(typeName){
        //获取表格对象
        var tb1 = $("#viewTabs");                // 找table的ID
//        var rowNum= $("#viewTabs tr").size();  //获取表格的行数
        //var liNum=$("tr[id^='_tr_']").size();  //获取以_tr_开头测tr个数

        if(typeName == "物料")
            var itemStr = $("select[name=batchNo]").val();
        if(typeName == "成品")
            var itemStr = $("select[name=size]").val();
        var itemArr = itemStr.split(",");
        var type = itemArr[0];
        var itemId = itemArr[1];
        var codeName = itemArr[2];
        var showName = itemArr[3];
        var size = itemArr[4];
        var prop = itemArr[5];
        var unit = itemArr[6];
        var storeId = itemArr[7];
        var batchNo = itemArr[8];
        var price = itemArr[9];
        var storageNumber = itemArr[10];

//        var codeName = $("select[name=codeId]").find("option:selected").text();

        if(type == "成品"){
            var serial = type + "," + itemId + "," + size + "," + batchNo;
        }else{
            var serial = type + "," + itemId + "," + "" + "," + batchNo;
        }

        if ($.inArray(serial, ids) >= 0) {
            alert("已添加过【" + serial + "】，请直接修改");
            return;
        }else{
            ids.push(serial);
        }

        var $td0 = $("<td></td>");
        $td0.html(type+"<input type=\'hidden\' class=\'input\' name=\'type_"+rowNum+"\' value=\'"+type+"\'/>");

        var $td1 = $("<td></td>"); //创建第一个td
        $td1.html(codeName+"<input type=\'text\' class=\'input\' name=\'item_id_"+rowNum+"\' value=\'"+itemId+"\'/>"); //html把序号放到了第一个td里面

        var $td2 = $("<td></td>");
        $td2.html(showName+"<input type=\'text\' class=\'input\' name=\'show_name_"+rowNum+"\' value=\'"+showName+"\'/>");

        var $td3 = $("<td></td>");
        $td3.html(size+"<input type=\'text\' class=\'input\' name=\'size_"+rowNum+"\' value=\'"+size+"\'/>");

        var $td4 = $("<td></td>");
        $td4.html(prop);

        var $td5 = $("<td></td>");
        $td5.html("<input type=\'text\' class=\'input batchNo\' name=\'batch_no_"+rowNum+"\' value=\'"+batchNo+"\' readonly/>"+"<input type=\'hidden\' class=\'input\' name=\'store_id_"+rowNum+"\' value=\'"+storeId+"\'/>");

        var $td6 = $("<td></td>");
        $td6.html("<input type=\'text\' class=\'input number\' name=\'number_"+rowNum+"\' onkeyup=\'onlyNumber(this)\' value='1'/> <input type=\'text\' class=\'input number\' name=\'storage_number_"+rowNum+"\' value='" + storageNumber +"' readonly/>");

        var $td7 = $("<td></td>");
        $td7.html(unit);

        var $td8 = $("<td></td>");
        $td8.html("<input type=\'text\' class=\'input price\' name=\'price_"+rowNum+"\' value='" + price +"' readonly/>");

//        var $td9 = $("<td></td>");
//        $td9.html("<input type=\'text\' class=\'input number\' name=\'storage_number_"+rowNum+"\' value='" + storageNumber +"' readonly/>");

        var $td9 = $("<td></td>");
        $td9.html("<input type=\'text\' class=\'input totalPrice\' name=\'total_price_"+rowNum+"\' readonly value='"+ price +"'/>");

        var $td10 = $("<td></td>");
        $td10.html("<a class=\'btn btn-danger btn-del\'> 移除</a>");

        var $tr = $("<tr id=\'_tr_"+rowNum+"\' class=\'in-opt\'></tr>");// 创建tr，将3个td放置到tr中
        $tr.append($td0);
        $tr.append($td1);
        $tr.append($td2);
        $tr.append($td3);
        $tr.append($td4);
        $tr.append($td5);
        $tr.append($td6);
        $tr.append($td7);
        $tr.append($td8);
        $tr.append($td9);
        $tr.append($td10);

        //在表格的最后追加新增的tr
        tb1.append($tr);

        var dateInput = $("input.J_date1")
        if (dateInput.length) {
            Wind.use('datePicker', function () {
                dateInput.datePicker();
            });
        }

//        $("select[name='codeId']").find("option").eq(0).prop("selected",true);
        $("select[name='batchNo']").find("option").eq(0).prop("selected",true);
        $("select[name='size']").find("option").eq(0).prop("selected",true);
        $(".addRow").hide();
//        var row = $("input[name=row]").val();
        rowNum++; //用于新增tr、td、属性下标
        $("input[name=row]").val(rowNum);
        $("select[name='out_store_id']").attr("readonly","readonly");
    }

    $(function() {

        function checkStorage() {


        }

        if("{$info.status}" == "-1" || "{$info.status}" == "1")
        {
            $(".addTransfer").hide();

        }
        if("{$info.status}" != ""){
            $("select[name='out_store_id']").attr("readonly","readonly");
            $("select[name='in_store_id']").attr("readonly","readonly");
        }

        $("select[name='transferType']").change(function () {
            if($("select[name='transferType']").val() == "物料"){
                $(".Material").show();
                $(".FinishedProduct").hide();
            }
            if($("select[name='transferType']").val() == "成品"){
                $(".FinishedProduct").show();
                $(".Material").hide();
            }
            $(".noStorage").hide();
            $(".addRow").hide();
            $(".codeList").hide();
            $(".batchNoList").hide();
            $(".nameList").hide();
            $(".sizeList").hide();
        });

        $("select[name='out_store_id']").change(function () {
            $(".noStorage").hide();
            $(".addRow").hide();
            $(".codeList").hide();
            $(".batchNoList").hide();
            $(".nameList").hide();
            $(".sizeList").hide();
        });

        $(".search").click(function() {
//            $("select[name=codeId]").show();
            $(".noStorage").hide();
            var storeId = $("select[name='out_store_id']").val();
            $(".addRow").hide();
            $(".batchNoList").hide();
            if(storeId  == 0){
                alert("请先选择【发料仓】");
                $("select[name='out_store_id']").focus();
                $("select[name='codeId']").find("option").eq(0).prop("selected",true);
                return false;
            }
            $("select[name=codeId]").empty();
            $("select[name=codeId]").append("<option value='0'></option>");
            var codeName = $("input[name=codeName]").val().toLowerCase();
            var listArr=<?php echo json_encode($listCode);?>;
            var list=eval(listArr);
            var count = 0;
            for(var i=0;i<list.length;i++){
                if(list[i]["name"].toLowerCase().indexOf(codeName) != -1){
                    var val = list[i]["code_id"] + "," + list[i]["material_name"] + "," + list[i]["spec"] + "," + list[i]["prop"] + "," + list[i]["unit"] + "," + list[i]["barcode"];
                    $("select[name=codeId]").append("<option value='"+val+"'>【"+list[i]["parent_name"]+"】"+list[i]["code_name"]+"</option>");
                    count++;
                }
            }
            if(count>0){
                $(".codeList").show();
                $("select[name=codeId]").focus();
            }else{
                $(".codeList").hide();
            }
        });

        $("select[name='codeId']").change(function () {
            var storeId = $("select[name='out_store_id']").val();
            $(".addRow").hide();
            if(storeId  == 0){
                alert("请先选择【发料仓】");
                $("select[name='out_store_id']").focus();
                $("select[name='codeId']").find("option").eq(0).prop("selected",true);
                return false;
            }

//            $("select[name=batchNo]").show();
            $("select[name=batchNo]").empty();
            $("select[name=batchNo]").append("<option value='0'></option>");
            var codeName = $("select[name='codeId']").val();
            var codeId = codeName.substring(0, codeName.indexOf(","));
            var storageArr=<?php echo json_encode($listStorageMaterial);?>;
            var count = 0;
            var list=eval(storageArr);
            for(var i=0;i<list.length;i++){
                if(list[i]["code_id"] == codeId && list[i]["store_id"] == storeId){
                    var val = list[i]["type"] + "," + list[i]["code_id"] + ","  + "【"+list[i]["parent_name"]+"】"+list[i]["code_name"] + "," + list[i]["material_name"] + "," + list[i]["spec"] + "," + list[i]["prop"] + "," + list[i]["unit"] + "," + list[i]["store_id"] + "," + list[i]["batch_no"] + "," + list[i]["price"]+ "," + list[i]["storage_number"];
                    $("select[name=batchNo]").append("<option value='"+val+"'>"+list[i]["batch_no"]+" (剩余 "+list[i]["storage_number"]+" "+list[i]["unit"]+"，"+list[i]["production_date"] +"~" + list[i]["expiry_date"] +"）</option>");
                    count++;
                }
            }
            if(count>0){
                $(".batchNoList").show();
                $(".noStorage").hide();
                $("select[name=batchNo]").focus();
            }else{
                $(".batchNoList").hide();
                $(".noStorage").show();
                $(".noStorage").html("仓库【" + $("select[name=out_store_id]").find("option:selected").text() + "】无库存");
            }
        });

        $("select[name='batchNo']").change(function () {
            if($("select[name='batchNo']").val() != 0){
                $(".addRow").show();
            }else{
                $(".addRow").hide();
            }
        });

        $(".search1").click(function() {
            $(".addRow").hide();
            $(".sizeList").hide();
            $("select[name=finishedProductId]").empty();
            $("select[name=finishedProductId]").append("<option value='0'></option>");
            var name = $("input[name=name]").val().toLowerCase();
            var listArr=<?php echo json_encode($listFinishedProduct);?>;
            var count = 0;
            var list=eval(listArr);
            var classId = $("select[name=classId]").val();
            for(var i=0;i<list.length;i++){
                if(classId > 0 && list[i]["class_id"] != classId){
                    continue;
                }
                if(list[i]["name"].toLowerCase().indexOf(name) != -1){
//                    var val = list[i]["finished_product_id"] + "," + list[i]["name"] + "," + list[i]["class_name"] + "," + list[i]["size"] + "," + list[i]["unit"] + "," + list[i]["barcode"] + "," + list[i]["supplier_id"]+ "," + list[i]["image_url"]+ "," + list[i]["size_detail"]+ "," + list[i]["supplier_name"];
                    var val = list[i]["finished_product_id"];
                    $("select[name=finishedProductId]").append("<option value='"+val+"'>["+list[i]["class_name"]+"] "+list[i]["name"]+"</option>");
                    count++;
                }
            }
            if(count>0){
                $(".nameList").show();
                $("select[name=finishedProductId]").focus();
            }else{
                $(".nameList").hide();
            }
        });

        $("select[name='finishedProductId']").change(function () {
            var storeId = $("select[name='out_store_id']").val();
            $(".addRow").hide();
            if(storeId  == 0){
                alert("请先选择【发料仓】");
                $("select[name='out_store_id']").focus();
                $("select[name='finishedProductId']").find("option").eq(0).prop("selected",true);
                return false;
            }

//            $("select[name=batchNo]").show();
            $("select[name=size]").empty();
            $("select[name=size]").append("<option value='0'></option>");
            var finishedProductId = $("select[name='finishedProductId']").val();
            var storageArr=<?php echo json_encode($listStorageFinishedProduct);?>;
            var count = 0;
            var list=eval(storageArr);
            for(var i=0;i<list.length;i++){
                if(list[i]["finished_product_id"] == finishedProductId && list[i]["store_id"] == storeId){
                    var val = list[i]["type"] + "," + list[i]["finished_product_id"] + ","  +list[i]["code_name"] + "," + list[i]["finished_product_name"] + "," + list[i]["size"] + "," + list[i]["class_name"] + "," + list[i]["unit"] + "," + list[i]["store_id"] + "," + list[i]["batch_no"] + "," + list[i]["price"]+ "," + list[i]["storage_number"];
                    $("select[name=size]").append("<option value='"+val+"'>【"+list[i]["size"]+"】剩余 "+list[i]["storage_number"]+" "+list[i]["unit"]+"，"+list[i]["production_date"] +"~" + list[i]["expiry_date"] + "，批号（" + list[i]["batch_no"]  +"）</option>");
                    count++;
                }
            }
            if(count>0){
                $(".sizeList").show();
                $(".noStorage").hide();
                $("select[name=size]").focus();
            }else{
                $(".sizeList").hide();
                $(".noStorage").show();
                $(".noStorage").html("仓库【" + $("select[name=out_store_id]").find("option:selected").text() + "】无库存");
            }

        });

        $("select[name='size']").change(function () {
            if($("select[name='size']").val() != ""){
                $(".addRow").show();
            }
        });

        $("button.btn_submit").click(function() {
            if(checkStorage() == 1)
                return false;
           if($("#viewTabs tr").size() == 1){
                alert("请增加调拨单");
                $("input[name=codeName]").focus();
                return false;
            }

            if ($("select[name=out_store_id]").val() == 0) {
                alert("请选择【调出仓】");
                $("select[name=out_store_id]").focus();
                return false;
            }

            if ($("select[name=in_store_id]").val() == 0) {
                alert("请选择【调入仓】");
                $("select[name=in_store_id]").focus();
                return false;
            }

            if ($("select[name=in_store_id]").val() == $("select[name=out_store_id]").val()) {
                alert("【调出仓】与【调入仓】相同");
                $("select[name=in_store_id]").focus();
                return false;
            }

            if (parseInt("{$info.status}") > -2){
               if ($("input[name=audit_date]").val() == 0) {
                    alert("请选择【审核时间】");
                    $("input[name=audit_date]").focus();
                    return false;
                }
            }else{
                if ($("input[name=transfer_date]").val() == 0) {
                    alert("请选择【调拨时间】");
                    $("input[name=transfer_date]").focus();
                    return false;
                }
            }
            var status = 0;
            var list = new Array();
            $.ajax({
                url:"{:U('Transfer/storageList')}",
                type:"post",
                data:{
//                    status: status,
//                    orderId: '{$orderId}'
                },
                dataType:"JSON",
                beforeSend:function(){
                    $("#loadingToast").show();
                },
                complete:function(){
                    $('#loadingToast').hide();
                },
                success:function(data){
                    list = data;
                    setTimeout(function() {
                        $(".ui-item.measure-info img").bind("click", function() {
                            var upUrl = "/Template/images/icon-up.png";
                            var downUrl = "/Template/images/icon-down.png";
                            $(this).parent().next().toggle();
                            if($(this).attr("src") == upUrl) {
                                $(this).attr("src", downUrl);
                            } else {
                                $(this).attr("src", upUrl);
                            }
                        });
                        $(".ui-item.measure-info img").each(function() {
                            $(this).trigger("click");
                        });
                    },200);

                    var row = $("input[name=row]").val();
                    for(var index=0;index<row;index++){
                        var itemId = $("input[name=item_id_"+index+"]").val();
                        var size = $("input[name=size_"+index+"]").val();
                        var number = parseFloat($("input[name=number_"+index+"]").val());
                        var type = $("input[name=type_"+index+"]").val();
                        var batchNo = $("input[name=batch_no_"+index+"]").val();
                        var storeId = $("select[name='out_store_id']").val();
                        var i;
                        for(i=0;i<list.length;i++){
                            if(list[i]["type"] == "成品" && list[i]["finished_product_id"] == itemId && list[i]["size"] == size && list[i]["type"] == type && list[i]["batch_no"] == batchNo && list[i]["store_id"] == storeId){
                                if(parseFloat(list[i]["storage_number"]) < number){
                                    $("input[name=number_"+index+"]").css('background','#ffd5c9');
                                    alert("【" + $("input[name=show_name_"+index+"]").val() + "】库存不足，剩余：" + list[i]["storage_number"]);
                                    status = 1;
                                }
                                break;
                            }
                            if(list[i]["type"] == "物料" && list[i]["code_id"] == itemId && list[i]["type"] == type && list[i]["batch_no"] == batchNo && list[i]["store_id"] == storeId){
                                if(parseFloat(list[i]["storage_number"]) < number){
                                    $("input[name=number_"+index+"]").css('background','#ffd5c9');
                                    alert("【" + $("input[name=show_name_"+index+"]").val() + "】库存不足，剩余：" + list[i]["storage_number"]);
                                    status = 1;
                                }
                                break;
                            }
                        }
                        if(i == list.length){
                            $("input[name=number_"+index+"]").css('background','#ffac96');
                            alert("【" + $("input[name=show_name_"+index+"]").val() + "】无库存，请移除该项");
                            status = 1;
                        }
                    }
                    if(status == 1){
                        return false;
                    }
                    if (confirm("提交采购入库将无法再次修改，是否继续提交")) {
                        $("button.btn_submit").hide();
                        $(".J_ajaxForm").attr("action", "{:U('Transfer/claimTransferPost')}");
                        $(".J_ajaxForm").submit();
                    } else {
                        return false;
                    }
                }
            });
            return false;
        });

        var listArr=<?php echo json_encode($list);?>;
        var list=eval(listArr);
        if(list != null){
            rowNum = list.length;
            for(var i=0;i<list.length;i++){
                var type = list[i]["type"];
                if(type == "成品"){
                    var size = list[i]["size"];
                    var itemId = list[i]["finished_product_id"];
                }else{
                    var size = "";
                    var itemId = list[i]["code_id"];
                }
                var batchNo = list[i]["batch_no"];
                var serial = type + "," + itemId + "," + size + "," + batchNo;
                ids.push(serial);
            }
        }else{
            rowNum = 0;
        }

        //移除
        $("#viewTabs").on('click', '.btn-del', function () {
            var type = $(this).closest('tr').children('td').eq(0).html();
            var codeId = $(this).closest('tr').children('td').eq(1).children('input').eq(0).val();
            if(type == "成品"){
                var size = $(this).closest('tr').children('td').eq(3).html();
            }else{
                var size = "";
            }
            var batchNo = $(this).closest('tr').children('td').eq(4).children('input').eq(0).val();
            var serial = type + "," + codeId + "," + size + "," + batchNo;
            ids.splice($.inArray(serial,ids),1);
            $(this).closest('tr').remove();
        });

        $("input[name=unAudit]").click(function() {
            if($("input[name=unAudit]").is(':checked')) {
                $("button.btn_submit").text("反审核");
                $("input[name=btnText]").val("反审核");
            }else{
                $("button.btn_submit").text("审核");
                $("input[name=btnText]").val("审核");
            }
        });
    });

</script>
<style type="text/css">
    .btn-danger,.btn-info,.btn-success,.btn-warning{
        width: 50px;
        /*height: 18px;*/
        padding: 2px 0px 2px 0px;
        margin: 1px 0px 1px 0px;
    }
    .code{
        width: 150px;
    }
    .batchNo{
        width: 150px;
    }
    .number{
        width: 40px;
    }
    .price{
        width: 100px;
    }
    .J_date{
        width: 100px;
    }
    .totalPrice{
        width: 100px;
    }
    .img-process{
        width: 70px;
        height: 70px;
        /*cursor: pointer;*/
    }
</style>
<div class="wrap jj">
    <div class="common-form">
        <form method="post" name="myForm" class="form-horizontal J_ajaxForm" action="">
            <fieldset>
                <a style="color:#45a1de;font-weight: bold;font-size: large">调拨单</a>
                &nbsp;&nbsp;&nbsp;
                <if condition="$info['status'] eq '1'">
                    <a style="color: #1cc385;font-weight: bold;font-size: large">（已审核）</a>
                </if>
                <if condition="$info['status'] eq '-1'">
                    <a style="color: #ed7667;font-weight: bold;font-size: large">（未审核）</a>
                </if>
                <br/><br/>
                <input type="hidden" name="id" value="{$info.transfer_id}" />
                <div class="control-group">
                    单号：<input type="text" name="transfer_no" value="{$info.transfer_no}" readonly/>
                    &nbsp;&nbsp;&nbsp;
                    调出仓：
                    <select name="out_store_id" style="width: auto">
                        {:getCommonSelectOptionHtml($info['out_store_id'], "Store", "store_id", "store_name", null,
                        $user['enterprise_code'], 1)}
                    </select>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    调入仓：
                    <select name="in_store_id" style="width: auto">
                        {:getCommonSelectOptionHtml($info['in_store_id'], "Store", "store_id", "store_name", null,
                        $user['enterprise_code'], 1)}
                    </select>
                    &nbsp;&nbsp;&nbsp;&nbsp;
                    <br/><br/>
                    备注：
                    <input type="text" class="input" style="width: 790px" name="remark" value="{$info.remark}">
                </div>
                <hr class="half-rule">
                <table class="table table-hover table-bordered" id="viewTabs">
                    <thead>
                        <tr>
                            <th style="min-width: 35px; width: 35px">类型</th>
                            <th style="min-width: 80px; width: 80px">编码</th>
                            <th>名称</th>
                            <th style="min-width: 50px;width: 200px">规格型号</th>
                            <th style="min-width: 30px;width: 70px">辅助属性</th>
                            <th style="min-width: 30px; width: 50px">批号</th>
                            <th style="min-width: 30px; width: 60px">数量</th>
                            <th style="min-width: 30px; width: 50px">单位</th>
                            <th style="min-width: 40px; width: 100px">单位成本</th>
                            <th style="min-width: 40px; width: 100px">成本</th>
                            <th style="min-width: 50px; width: 50px">操作</th>
                        </tr>
                    </thead>
                    <tbody>
                        <foreach name="list" item="vo" key="k">
                            <tr>
                                <if condition="$vo['type'] eq '物料'">
                                    <td>
                                        {$vo.type}
                                        <input type="hidden" class="input" name="type_{$k}" value="{$vo.type}" >
                                    </td>
                                    <td>
                                        【{$vo.parent_name}】{$vo.code_name}
                                        <input type="text" class="input" name="item_id_{$k}" value="{$vo.code_id}" >
                                        <input type="text" class="input" name="transfer_item_id_{$k}" value="{$vo.transfer_item_id}" >
                                    </td>
                                    <td>{$vo.material_name}<input type="text" class="input" name="show_name_{$k}" value="{$vo.material_name}" ></td>
                                    <td>{$vo.spec}</td>
                                    <td>{$vo.prop}</td>
                                    <td>
                                        <input type="text" class="input batchNo" name="batch_no_{$k}" value="{$vo.material_barcode}" readonly>
                                        <!--<input type="text" class="input store_id" name="store_id_{$k}" value="{$vo.store_id}">-->
                                    </td>
                                    <td><input type="text" class="input number" name="number_{$k}" value="{$vo.number}" onkeyup="onlyNumber(this)"></td>
                                    <td>{$vo.material_unit}</td>
                                    <td><input type="text" class="input price" name="price_{$k}" value="{$vo.price}" readonly></td>
                                    <php>
                                        $totalPrice = $vo["price"] * $vo["number"];
                                    </php>
                                    <td><input type="text" class="input totalPrice" name="total_price_{$k}" value="{$totalPrice}" readonly></td>
                                </if>
                                <if condition="$vo['type'] eq '成品'">
                                    <td>
                                        {$vo.type}
                                        <input type="hidden" class="input" name="type_{$k}" value="{$vo.type}" >
                                    </td>
                                    <td>
                                        {$vo.finished_product_code}
                                        <input type="text" class="input" name="item_id_{$k}" value="{$vo.finished_product_id}" >
                                        <input type="text" class="input" name="transfer_item_id_{$k}" value="{$vo.transfer_item_id}" >
                                    </td>
                                    <td>{$vo.finished_product_name}<input type="text" class="input" name="show_name_{$k}" value="{$vo.finished_product_name}" ></td>
                                    <td>{$vo.size}<input type="text" class="input" name="size_{$k}" value="{$vo.size}" ></td>
                                    <td>{$vo.class_name}</td>
                                    <td>
                                        <input type="text" class="input batchNo" name="batch_no_{$k}" value="{$vo.batch_no}" readonly>
                                        <!--<input type="text" class="input store_id" name="store_id_{$k}" value="{$vo.store_id}">-->
                                    </td>
                                    <td><input type="text" class="input number" name="number_{$k}" value="{$vo.number}" onkeyup="onlyNumber(this)"></td>
                                    <td>{$vo.finished_product_unit}</td>
                                    <td><input type="text" class="input price" name="price_{$k}" value="{$vo.price}" readonly></td>
                                    <php>
                                        $totalPrice = $vo["price"] * $vo["number"];
                                    </php>
                                    <td><input type="text" class="input totalPrice" name="total_price_{$k}" value="{$totalPrice}" readonly></td>
                                </if>
                                <if condition="$info['status'] neq '-1' && $info['status'] neq '1'">
                                    <td>
                                        <a class="btn btn-danger btn-del">移除</a>
                                    </td>
                                </if>
                            </tr>
                        </foreach>
                    </tbody>
                </table>
                <div class="addTransfer">
                    <div class="control-group" style="font-weight: bold">
                        添加：
                        <select name="transferType" style="width: auto">
                            <option value="调拨类型">调拨类型</option>
                            <option value="物料">物料</option>
                            <option value="成品">成品</option>
                        </select>
                    </div>
                    <div class="control-group Material" style="color: #45a1de;display: none">
                        物料名称：
                        <input type="text" class="input" name="codeName" value="">
                        <a class="btn btn-info search">搜索</a>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <div class="codeList" style="color: #45a1de;display: none">
                            物料列表：
                            <select name="codeId" style="width: auto">
                                <option value='0'></option>
                            </select>
                            &nbsp;&nbsp;
                            <span style="color: #de7d74;display: none" class="noStorage">无库存</span>
                        </div>
                        <div class="batchNoList" style="color: #1cc385;display: none">
                            批号列表：
                            <select name="batchNo" style="width: auto">
                                <option value='0'></option>
                            </select>
                            <a class="btn btn-success addRow" onclick='javascript:insertRows("物料")' style="display: none">添加</a>
                        </div>
                    </div>
                    <div class="control-group FinishedProduct" style="color: #1cc385;display: none">
                        成品分类：
                        <select style="width: 150px" name="classId">
                            {:getClassSelectOptionHtml(null, 1, $user['enterprise_code'])}
                        </select>
                        <br/>
                        成品名称：
                        <input type="text" class="input" name="name" value="">
                        <a class="btn btn-info search1">搜索</a>
                        &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                        <div class="nameList" style="color: #1cc385;display: none;">
                            成品列表：
                            <select style="width: auto" name="finishedProductId">
                                <option value='0'></option>
                            </select>
                            &nbsp;&nbsp;
                            <span style="color: #de7d74;display: none" class="noStorage">无库存</span>
                        </div>
                        <div class="sizeList" style="color: #1cc385;display: none;">
                            规格列表：
                            <select style="width: auto" name="size">
                                <option value='0'></option>
                            </select>
                            <a class="btn btn-success addRow" onclick='javascript:insertRows("成品")' style="display: none">添加</a>
                        </div>
                    </div>
                </div>
                <input type="text" name="row" value="{$row}"/>
                <hr class="half-rule">
                <div class="control-group">
                    <if condition="$info['status'] gt '-2'">
                        调拨时间：
                        <input type="text" class="input J_date" style="width: 150px" name="transfer_date" value="{$info.transfer_date}" autocomplete="off" readonly>
                        &nbsp;&nbsp;&nbsp;
                        调拨人：
                        <select readonly>
                            {:getCommonSelectOptionHtml($claimer['employee_id'], "Admin", "employee_id", "admin_name", null, $user['enterprise_code'], 1)}
                        </select>
                        <br/><br/>
                        审核时间：
                        <input type="text" class="input J_date" style="width: 150px" name="audit_date" value="{$info.audit_date}" autocomplete="off">
                        &nbsp;&nbsp;&nbsp;
                        审核人：
                        <select name="auditor" readonly>
                            {:getCommonSelectOptionHtml($user['employee_id'], "Admin", "employee_id", "admin_name", null, $user['enterprise_code'], 1)}
                        </select>
                        &nbsp;&nbsp;&nbsp;
                        审核说明：
                        <input type="text" class="input" style="width: 350px" name="audit_note" value="{$info.audit_note}" autocomplete="off">

                        <else/>

                        调拨时间：
                        <input type="text" class="input J_date" style="width: 150px" name="transfer_date" value="{$info.transfer_date}" autocomplete="off">
                        &nbsp;&nbsp;&nbsp;
                        调拨人：
                        <select readonly>
                            {:getCommonSelectOptionHtml($user['employee_id'], "Admin", "employee_id", "admin_name", null, $user['enterprise_code'], 1)}
                        </select>
                        <br/><br/>
                        审核时间：
                        <input type="text" class="input J_date" style="width: 150px" name="audit_date" value="{$info.audit_date}" autocomplete="off" readonly>
                        &nbsp;&nbsp;&nbsp;
                        审核人：
                        <select name="auditor" readonly>
                            {:getCommonSelectOptionHtml($auditor['employee_id'], "Admin", "employee_id", "admin_name", null, $user['enterprise_code'], 1)}
                        </select>
                        &nbsp;&nbsp;&nbsp;
                        审核说明：
                        <input type="text" class="input" style="width: 350px;color: #ed7667" name="audit_note" value="{$info.audit_note}" autocomplete="off" readonly>


                    </if>
                </div>
                <if condition="$info['status'] eq '-1'">
                <div class="control-group">
                    <div class="controls">
                        <label class="checkbox inline" style="font-weight: bold">
                            <input type="checkbox"  name="unAudit">反审核
                        </label>
                    </div>
                </div>
                </if>
            </fieldset>
            <div class="form-actions">
                <php>
                    $btnText = "调拨";
                    $btnStatus = -1;
                    $role = explode(',',$user["role"]);
                    if(in_role($role,"8")){
                        if($info["status"] == -2 || isNullOrEmpty($info["status"])){
                            $btnText = "调拨";
                            $btnStatus = 1;
                        }else{
                            $btnText = "已调拨";
                            $btnStatus = -1;
                        }
                    }
                    if(in_role($role,"4")){
                        if($info["status"] == -1){
                            $btnText = "审核";
                            $btnStatus = 1;
                        }
                        if($info["status"] == 1){
                            $btnText = "反审核";
                            $btnStatus = 1;
                        }
                    }
                </php>
                <if condition="$btnStatus eq 1">
                    <button type="submit" class="btn btn-primary btn_submit ">{$btnText}</button>
                    <else/>
                    <button disabled="disable" style="background-color: #93949c" class="btn btn-primary btn_submit">{$btnText}</button>
                </if>
                <input type="hidden" name="id" value="{$info.transfer_id}" />
                <input type="hidden" name="btnText" value="{$btnText}"/>
                <a class="btn" href="__URL__">返回</a>
            </div>
        </form>
    </div>
</div>
<script src="__ROOT__/statics/js/common.js"></script>
</body>
</html>